#ifndef SRC_CORE_ASYNC_PACKET_SOCKET_H_
#define SRC_CORE_ASYNC_PACKET_SOCKET_H_

#include "base/refcount.h"
#include "base/sigslot.h"
#include "base/scoped_ptr.h"
#include "base/scoped_ref_ptr.h"
#include "base/socketaddress.h"
#include "base/asyncsocket.h"
#include "base/logging.h"

#define DEFAULT_MAX_PACKET_SIZE 64*1024

namespace vz {

class AsyncPacketSocket : public RefCountInterface,
  public sigslot::has_slots<> {
 public:
  typedef scoped_refptr<AsyncPacketSocket> Ptr;

  sigslot::signal1<AsyncPacketSocket::Ptr> SignalConnectEvent;

  sigslot::signal4<AsyncPacketSocket::Ptr,
          uint16,
          const char*,
          uint32> SignalPacketEvent;

  sigslot::signal1<AsyncPacketSocket::Ptr> SignalWriteEvent;

  sigslot::signal2<AsyncPacketSocket::Ptr, int> SignalCloseEvent;

  virtual SocketAddress GetLocalAddress() const = 0;

  virtual SocketAddress GetRemoteAddress() const = 0;

  virtual void SetError(int error) = 0;

  virtual int GetError() const = 0;

  virtual int Connect(const SocketAddress &address) = 0;

  virtual int SendPacket(int16 cmd,
                         const void *data = NULL,
                         uint32 data_size = 0) = 0;

  virtual int Close() = 0;
};

}  // namespace vz

#endif  // SRC_CORE_ASYNC_PACKET_SOCKET_H_



